package com.example.ymm.modules1.service.dd.ms;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
import com.example.ymm.modules1.entity.my.ms.MsMouldMain;
import com.example.ymm.modules1.entity.my.sys.SysApprovalSetting;
import com.example.ymm.modules1.entity.my.user.DbApprovalLog;
import com.example.ymm.modules1.entity.my.user.DbUserWait;
import com.example.ymm.modules1.service.dto.heng.ApproverMsgNotifyDto;
import com.example.ymm.util.ServletUtils;
import com.example.ymm.util.UtilValidate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class DingNoticeService {

    /**
     * 二次开发系统通知
     */

    @Value("${dd_h5.agentId}")
    private Long agentId;

    @Value("${dd_h5.appId}")
    String appId;

    @Value("${dd_h5.corpid}")
    String corpid;

    @Autowired
    AccessTokenH5Service2 accessTokenH5Service;

    /**
     * 模具费用待办通知
     */
    public void OATempleNotice(MsMouldMain mouldMain)  {
        if(UtilValidate.isEmpty(mouldMain)){
            return;
        }
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(mouldMain.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("FFFF6A00");
        head.setText("请尽快处理");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("金额:");
        form1.setValue(mouldMain.getPrice().doubleValue()+"");
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("开始时间:");
        form2.setValue(mouldMain.getStartDate());
        OapiMessageCorpconversationAsyncsendV2Request.Form form3 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form3.setKey("经办人:");
        form3.setValue(mouldMain.getUserName());

//        OapiMessageCorpconversationAsyncsendV2Request.Rich rich = new OapiMessageCorpconversationAsyncsendV2Request.Rich();
//        rich.setNum("200");
//        rich.setUnit("元");

        list.add(form1);
        list.add(form2);
        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle("模具费用退款待确认通知");
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0xFFFF6A00");
        statusBar.setStatusValue("进行中");
        String url="http://220.161.77.66:10111/#/h5Login?redirect=/ms/mouldList";
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }

    /**
     * 待审批通知
     */
    public void approvaWaitNotice(DbUserWait wait,SysApprovalSetting approvalSetting)  {
        if(UtilValidate.isEmpty(wait)){
            return;
        }
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(wait.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("FFFF6A00");
        head.setText("请尽快处理");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("审批编号:");
        form1.setValue(wait.getApproveNo());
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("审批类型:");
        form2.setValue(approvalSetting.getApprovalName());
        OapiMessageCorpconversationAsyncsendV2Request.Form form3 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form3.setKey("发起人:");
        form3.setValue(wait.getCreateUserName());

//        OapiMessageCorpconversationAsyncsendV2Request.Rich rich = new OapiMessageCorpconversationAsyncsendV2Request.Rich();
//        rich.setNum("200");
//        rich.setUnit("元");

        list.add(form1);
        list.add(form2);
        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle(wait.getTitle());
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0xFFFF6A00");
        statusBar.setStatusValue("进行中");
        String url="http://220.161.77.66:10111/#/h5Login?redirect="+approvalSetting.getPage();
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }


    /**
     * 参与人 通知
     */
    public void approvaJoinNotice(ApproverMsgNotifyDto dto)  {
        if(UtilValidate.isEmpty(dto)){
            return;
        }
        SysApprovalSetting approvalNameSetting = dto.getApprovalNameSetting();

        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(dto.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("9999FF");
        head.setText("请知悉");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("审批编号:");
        form1.setValue(dto.getApproveNo());
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("审批名称:");
        form2.setValue(approvalNameSetting.getApprovalName());
        OapiMessageCorpconversationAsyncsendV2Request.Form form3 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form3.setKey("发起人:");
        form3.setValue(dto.getCreateUserName());

//        OapiMessageCorpconversationAsyncsendV2Request.Rich rich = new OapiMessageCorpconversationAsyncsendV2Request.Rich();
//        rich.setNum("200");
//        rich.setUnit("元");

        list.add(form1);
        list.add(form2);
        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle(dto.getCreateUserName()+"发起了《"+approvalNameSetting.getApprovalName()+"》");
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0xFFFF6A00");
        statusBar.setStatusValue("进行中");
        String url="http://220.161.77.66:10111/#/h5Login?redirect="+approvalNameSetting.getPage();
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }


    /**
     * 审批驳回
     */
    public void approvaBackNotice(DbApprovalLog approvalLog, String comment, String userName, SysApprovalSetting approvalNameSetting)  {

        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(approvalLog.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("FF0000");
        head.setText("点击查看");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("审批编号:");
        form1.setValue(approvalLog.getApproveNo());
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("驳回原因:");
        form2.setValue(comment);
        OapiMessageCorpconversationAsyncsendV2Request.Form form3 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form3.setKey("审批人:");
        form3.setValue(userName);

//        OapiMessageCorpconversationAsyncsendV2Request.Rich rich = new OapiMessageCorpconversationAsyncsendV2Request.Rich();
//        rich.setNum("200");
//        rich.setUnit("元");

        list.add(form1);
        list.add(form2);
        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle("您的"+approvalNameSetting.getApprovalName()+"被驳回");
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0xFF0000");
        statusBar.setStatusValue("驳回");
        String url="http://220.161.77.66:10111/#/h5Login?redirect="+approvalNameSetting.getPage();
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }


    /**
     * 审批撤回
     */
    public void approvalCancelNotice(ApproverMsgNotifyDto dto){
        if(UtilValidate.isEmpty(dto)){
            return;
        }
        SysApprovalSetting approvalNameSetting = dto.getApprovalNameSetting();
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(dto.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("9999FF");
        head.setText("请知悉");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("审批编号:");
        form1.setValue(dto.getApproveNo());
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("审批名称:");
        form2.setValue(dto.getApproverName());
        OapiMessageCorpconversationAsyncsendV2Request.Form form3 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form3.setKey("发起人:");
        form3.setValue(dto.getCreateUserName());

//        OapiMessageCorpconversationAsyncsendV2Request.Rich rich = new OapiMessageCorpconversationAsyncsendV2Request.Rich();
//        rich.setNum("200");
//        rich.setUnit("元");

        list.add(form1);
        list.add(form2);
        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle(dto.getCreateUserName()+"撤回了《"+dto.getApproverName()+"》");
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0xFFFF6A00");
        statusBar.setStatusValue("已撤回");
        String url="http://220.161.77.66:10111/#/h5Login?redirect="+approvalNameSetting.getPage();
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }


    /**
     * 审批全部通过
     */
    public void approvaAllPassNotice(DbApprovalLog approvalLog,String comment,SysApprovalSetting approvalSetting)  {
        if(UtilValidate.isEmpty(approvalLog)){
            return;
        }
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(approvalLog.getUserId());
        request.setToAllUser(false);

        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();

        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
        head.setBgcolor("00FFFF");
        head.setText("点击查看");
        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
        List<OapiMessageCorpconversationAsyncsendV2Request.Form> list = new ArrayList<>();
        OapiMessageCorpconversationAsyncsendV2Request.Form form1 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form1.setKey("审批编号:");
        form1.setValue(approvalLog.getApproveNo());
        OapiMessageCorpconversationAsyncsendV2Request.Form form2 = new OapiMessageCorpconversationAsyncsendV2Request.Form();
        form2.setKey("已审批完成:");
        form2.setValue(comment);

        list.add(form1);
        list.add(form2);
//        list.add(form3);


        body.setForm(list);
//        body.setRich(rich);
        body.setTitle("您的"+approvalSetting.getApprovalName()+"已通过");
//        body.setImage("@lADOADmaWMzazQKA");
//        body.setFileCount("3");
//        body.setAuthor("小钉");


        OapiMessageCorpconversationAsyncsendV2Request.StatusBar statusBar = new OapiMessageCorpconversationAsyncsendV2Request.StatusBar();
        statusBar.setStatusBg("0x00FF00");
        statusBar.setStatusValue("审批完成");
        String url="http://220.161.77.66:10111/#/h5Login?redirect="+approvalSetting.getPage();
        String encode= ServletUtils.urlEncode(url);
        String message_url= "dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+encode;//&redirect_url=/h5Login
        String message_url3="dingtalk://dingtalkclient/action/openapp?corpid="+corpid+"&container_type=work_platform&app_id="+agentId+"&redirect_type=jump&redirect_url=h5Login";

        String message_url2="dingtalk://dingtalkclient/page/link?url="+encode+"&pc_slide=true";
        //http://220.161.77.66:10111/#/h5Login
        oa.setMessageUrl(message_url);
        oa.setHead(head);
        oa.setBody(body);
        oa.setStatusBar(statusBar);
        msg.setOa(oa);
        msg.setMsgtype("oa");
        msg.setOa(oa);
        request.setMsg(msg);

        String accessToken = accessTokenH5Service.getAccessToken();
        try{
            OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, accessToken);
            System.out.println(rsp.getBody());

        }catch (Exception e){
            log.error(e.getMessage(),e);
        }
    }




}
